<template>
  <div style="height: calc(100vh - 130px);overflow: hidden;position: relative">
    <div style="position: absolute;top: 10px;right: 20px;display: flex;flex-flow: row nowrap;justify-content: center">
      <el-button icon="el-icon-refresh" type="success" title="刷新" :disabled="loading" @click="refresh" />
    </div>
    <div ref="logRef" v-loading="loading" style="background-color: #333333; color: lavender;overflow: auto;height: 100%;font-size: small;padding: 5px 5px 20px">
      <div v-for="(item,index) in contents" :key="index" style="display: flex;justify-content: flex-start;flex-flow: row wrap">
        <div id="index" style="color: #67c23a;width: 50px;text-align: center">{{index}}</div>
        <div>{{ item }}</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "Log",
  data() {
    return {
      loading: false,
      contents: ''
    }
  },
  created() {
    this.refresh()
  },
  methods: {
    refresh(){
      this.loading = true
      this.$get('admin/log/print')
          .then(res => {
            this.contents = res.data
            this.loading = false
            setTimeout(()=> {
              let scrollEl = this.$refs.logRef;
              scrollEl.scrollTo({ top: scrollEl.scrollHeight });
            }, 500)
          })
    }
  }
}
</script>

<style scoped>

</style>
